<template>
	<view class="smEnterhouse">
		<view class="cartTitle">
			<view class="cartTitle_item">
				商品名称：
				<view style="display: inline-block;width: 60%;">
					<u-input 
						v-model="cartName" 
						placeholder="请输入商品名称" 
						:type="type" 
						:border="true"
						border-color="#707070FF"/>
				</view>
			</view>
			<view class="cartTitle_item">
				商品编号：
				<view style="display: inline-block;width: 60%;font-size: 30rpx;color: #AAAAAAFF;">
					{{cartID}}
				</view>
			</view>
			<view class="cartTitle_item" @click="showCartSelect = true">
				<view>
					商品类别：
					<view style="border-radius: 9.52rpx;display: inline-block;border: 1rpx solid #707070FF;">
						<text style="color: #2276BCFF;margin-left: 13.35rpx;">{{selectCartType_value}}</text>
						<view style="display: inline-block;margin-left: 66.75rpx;margin-right: 13.35rpx;">
							<u-icon name="arrow-down" color="#707070FF" size="35"></u-icon>
						</view>
					</view>
				</view>
				<u-select 
				title="商品类别" 
				:mask-close-able="false" 
				:default-value="[selectCartValue_default]" 
				v-model="showCartSelect" 
				:list="selectCartlist" 
				@confirm="selectCartType">
				</u-select>
			</view>
			<view class="cartTitle_item" @click="showkuSelect = true">
				<view>
					入库仓库：
					<view style="border-radius: 9.52rpx;display: inline-block;border: 1rpx solid #707070FF;">
						<text style="color: #2276BCFF;margin-left: 13.35rpx;">{{kuSelectType_value}}</text>
						<view style="display: inline-block;margin-left: 66.75rpx;margin-right: 13.35rpx;">
							<u-icon name="arrow-down" color="#707070FF" size="35"></u-icon>
						</view>
					</view>
				</view>
				<u-select 
				title="入库仓库" 
				:mask-close-able="false" 
				:default-value="[kuSelectValue_default]" 
				v-model="showkuSelect" 
				:list="selectKulist" 
				@confirm="selectKuType">
				</u-select>
			</view>
		</view>
		<view class="cartType">
			<view class="cartType_item" v-show="showRadio">
				<view>
					灶具进风：
					<view style="display: inline-block;vertical-align:middle;">
						<u-radio-group v-model="jingfen_value">
							<u-radio
								v-for="(item, index) in jingfen" :key="index" 
								:name="item.name"
								:disabled="item.disabled"
								active-color="#BB0000FF"
							>
								{{item.name}}
							</u-radio>
						</u-radio-group>
					</view>
				</view>
			</view>
			<view class="cartType_item" v-show="showRadio">
				<view>
					灶具出风：
					<view style="display: inline-block;vertical-align:middle;">
						<u-radio-group v-model="chufen_value">
							<u-radio
								v-for="(item, index) in chufen" :key="index" 
								:name="item.name"
								:disabled="item.disabled"
								active-color="#BB0000FF"
							>
								{{item.name}}
							</u-radio>
						</u-radio-group>
					</view>
				</view>
			</view>
			<view class="cartType_item" v-show="showRadio">
				<view>
					灶眼数量：
					<view style="display: inline-block;vertical-align:middle;">
						<u-radio-group v-model="zaoyan_value">
							<u-radio
								v-for="(item, index) in zaoyan" :key="index" 
								:name="item.name"
								:disabled="item.disabled"
								active-color="#BB0000FF"
							>
								{{item.name}}
							</u-radio>
						</u-radio-group>
					</view>
				</view>
			</view>
			<view class="cartType_item"  v-show="showRadio">
				<view>
					气源类别：
					<view style="display: inline-block;vertical-align:middle;">
						<u-radio-group v-model="qiyuan_value">
							<u-radio
								v-for="(item, index) in qiyuan" :key="index" 
								:name="item.name"
								:disabled="item.disabled"
								active-color="#BB0000FF"
							>
								{{item.name}}
							</u-radio>
						</u-radio-group>
					</view>
				</view>
			</view>
			<view class="cartType_item bz">
				备注：<u-input v-model="bz_content" type="textarea" :border="false" :height="96" :auto-height="true" />
			</view>
			<view class="subimt_ruku">
				<yt-botton btname="确定入库" @click="ruku"></yt-botton>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import ytBotton from '../../comment/yt-botton.vue'
	export default {
		data() {
			return {
				cartID:"",
				cartName:"",
				showCartSelect:false,
				selectCartlist:[ //主机电器、头部、水槽、配件、赠品
					{
						value: '1',
						label: '主机电器'
					},
					{
						value: '2',
						label: '头部'
					}								
				],
				selectCartValue_default:'0',
				selectCartType_value:'主机电器',
				showkuSelect:false,
				selectKulist:[ //富安居、万泰隆、快环、澳华、吴圩、荣宝华、迷你厂、京东、总仓库。
					{
						value: '1',
						label: '富安居'
					},
					{
						value: '2',
						label: '万泰隆'
					},
					{
						value: '3',
						label: '快环'
					},
					{
						value: '4',
						label: '澳华'
					},
					{
						value: '5',
						label: '吴圩'
					},
					{
						value: '6',
						label: '荣宝华'
					},
					{
						value: '7',
						label: '迷你厂'
					},
					{
						value: '8',
						label: '京东'
					},
					{
						value: '9',
						label: '总仓库'
					}			
				],
				kuSelectValue_default:'8',
				kuSelectType_value:'总仓库',
				jingfen:[
					{
						name: '上进风',
						disabled: false
					},{
						name: '下进风',
						disabled: false
					},{
						name: '全进风',
						disabled: false
					}
				],
				jingfen_value:'上进风',
				chufen:[//左出风   右出风   左右通用
					{
						name: '左出风',
						disabled: false
					},{
						name: '右出风',
						disabled: false
					},{
						name: '左右通用',
						disabled: false
					}
				],
				chufen_value:'左出风',
				zaoyan:[//双眼 单眼
					{
						name: '双眼',
						disabled: false
					},{
						name: '单眼',
						disabled: false
					}
				],
				zaoyan_value:'双眼',
				qiyuan:[//天然气 液化气
					{
						name: '天然气',
						disabled: false
					},{
						name: '液化气',
						disabled: false
					}
				],
				qiyuan_value:'天然气',
				bz_content:'',
				showRadio:true
			};
		},
		onLoad(option) {
			this.cartID = option.result
		},
		methods:{
			selectCartType(e){
				this.selectCartValue_default = e[0].value - 1
				this.selectCartType_value = e[0].label
				if(e[0].value == 1){
					this.showRadio = true
				}else{
					this.showRadio = false
					this.jingfen_value = ""
					this.chufen_value = ""
					this.zaoyan_value = ""
					this.qiyuan_value = ""
				}
			},
			selectKuType(e){
				this.kuSelectValue_default = e[0].value - 1
				this.kuSelectType_value = e[0].label
			},
			ruku(){
				var Vue = this;
				uni.showModal({
					title:'商品入库',
					content:`您确定入库商品(${Vue.cartName})？`,
					showCancel:true,
					success(res) {
						if(res.confirm){
							uni.showLoading({
								title:"入库中。。。"
							})
							uniCloud.callFunction({
								name: 'uni-id-cf_mobile',
								data: {
									action:"enterhouse",
									params:{
										cart_name_enterhouse:Vue.cartName,
										cart_id_enterhouse:Vue.cartID,
										cart_type_enterhouse:Vue.selectCartType_value,
										cart_depository_enterhouse:Vue.kuSelectType_value,
										cook_utensils_jf_enterhouse:Vue.jingfen_value,
										cook_utensils_cf_enterhouse:Vue.chufen_value,
										cook_utensils_eyes_enterhouse:Vue.zaoyan_value,
										cook_utensils_qtype_enterhouse:Vue.qiyuan_value,
										cart_num_enterhouse:1,
										comment_enterhouse:Vue.bz_content
									}
								}
							}).then(({result}) => {
								uni.hideLoading()
								if(result.code == 0){
									Vue.$refs.uToast.show({
										title:result.msg ,
										type: 'success',
										position:"top",
										url:'../index/index'
									})
								}else{
									Vue.$refs.uToast.show({
										title:result.msg+",请重新登录！",
										type: 'error',
										position:"top"
									})
								}
								console.log(result)
							}).catch(err => {
								uni.hideLoading()
								console.log(err)
							})
						}
					}
				})
			}
		},
		components:{
			ytBotton
		}
	}
</script>

<style lang="scss">
.smEnterhouse{
	position: absolute;
	width: 100%;
	min-height: 1480rpx;
	background-color: #EEEEEEFF;
	.cartTitle{
		margin: 37.38rpx 0;
		padding: 32.04rpx;
		background-color: #fff;
		.cartTitle_item{
			padding: 26.7rpx 0;
			font-size: 30rpx;
		}
	}
	.cartType{
		.cartType_item{
			padding: 26.7rpx 32.04rpx;
			background-color: #FFFFFF;
			margin-bottom:21.36rpx ;
			font-size: 30rpx;
		}
		.bz{
			min-height: 256.32rpx;
		}
		
	}
	.subimt_ruku{
		margin-top: 77.43rpx;
	}
}
</style>
